home *** CD-ROM | disk | FTP | other *** search
- // The 'yum ' Gestalt values. They seem to be the same on Graphite
- // iBooks and iMacs. Convenient. Flavored iMacs available at MacHack
- // don't seem to have this Gestalt selector. My (Geoff Adams') Lombard
- // doesn't. iBooks do.
-
- #define kTangerineYum 0x0000083c
- #define kBlueberryYum 0x00000835
- #define kGraphiteYum 0x0000083e
-
- // The RGB values we've selected almost at random:
-
- #define kTangerineColor_Red 0xFFFF
- #define kTangerineColor_Green 0x91EA
- #define kTangerineColor_Blue 0x3333
-
- #define kBlueberryColor_Red 0x5b5b
- #define kBlueberryColor_Green 0x8787
- #define kBlueberryColor_Blue 0xf2f2
-
- #define kGraphiteColor_Red 0xc228
- #define kGraphiteColor_Green 0xc228
- #define kGraphiteColor_Blue 0xc228
-
-
-
- #if TARGET_CPU_68K && !TARGET_RT_MAC_CFM
- #error Sorry Can't do that
- #endif
-
- //#include <MixedMode.h>
- //#include <Appearance.h>
- //#include <SpeechSynthesis.h>
- #include <A4Stuff.h>
-
- #include <Files.h>
- #include <Folders.h>
- #include <Gestalt.h>
- #include <Resources.h>
- #include <Quickdraw.h>
-
-
- // Tell MetroWerks the procInfo for main
- ProcInfoType __procinfo = kPascalStackBased;
- pascal void main(void)
- {
- THz theZone;
-
- long yumValue;
- RGBColor machineColor;
-
- OSErr theErr;
- UInt16 index;
- short vRefNum;
- long dirID;
-
- CInfoPBRec cPB;
- OSErr result;
- FSSpec xDBGR_Startup;
- Boolean found = false;
-
- FSSpec debuggerSpec;
- Handle mctbRes;
-
- // get globals
- EnterCodeResource();
-
- // make sure we are in the system heap
- // (We probably don't need to do this.)
- theZone = GetZone();
- SetZone(SystemZone());
-
- // DebugStr("\pWe're off!");
-
- // First, Get the 'yum ' Gestalt value. This contains a description of the
- // color, presumably among other things.
- theErr = Gestalt('yum ', &yumValue);
- if (theErr == noErr) {
-
- // Well, we have a Yum! value. Keep going...
- // Figure out what color it should be.
- switch (yumValue) {
-
- case kTangerineYum:
- machineColor.red = kTangerineColor_Red;
- machineColor.green = kTangerineColor_Green;
- machineColor.blue = kTangerineColor_Blue;
- break;
-
- case kBlueberryYum:
- machineColor.red = kBlueberryColor_Red;
- machineColor.green = kBlueberryColor_Green;
- machineColor.blue = kBlueberryColor_Blue;
- break;
-
- case kGraphiteYum:
- machineColor.red = kGraphiteColor_Red;
- machineColor.green = kGraphiteColor_Green;
- machineColor.blue = kGraphiteColor_Blue;
- break;
-
- default:
- DebugStr("\pUnknown yum value.");
-
- }
-
-
- // Find the xDBGR_Startup INIT file (creator 'DBGR').
- // Get its 'TDid' resrource, which contains the dirID of the directory
- // containing "The Debugger"
- theErr = FindFolder(-1, kExtensionFolderType, false /* createFolder */,
- &vRefNum, &dirID);
-
- index = 1;
- do {
- cPB.dirInfo.ioFDirIndex = index;
- cPB.dirInfo.ioVRefNum = vRefNum;
- cPB.dirInfo.ioDrDirID = dirID;
- result = PBGetCatInfoSync(&cPB);
-
- if ( result == noErr ) {
- if ( (cPB.hFileInfo.ioFlAttrib & ioDirMask) == 0 &&
- cPB.hFileInfo.ioFlFndrInfo.fdType == 'INIT' &&
- cPB.hFileInfo.ioFlFndrInfo.fdCreator == 'DBGR') {
-
- FSMakeFSSpec(vRefNum, dirID, cPB.hFileInfo.ioNamePtr, &xDBGR_Startup);
- found = true;
-
- }
- } else {
- // DebugStr("\pPBGetCatInfoSync returned an error.");
- }
-
- ++index; /* prepare to get next item */
- } while ( result == noErr && ! found); /* time to fall back a level? */
-
- // if (! found)
- // DebugStr("\pFailed to find xDBGR_Startup");
-
- // If we fail to find xDBGR_Startup, who the hell cares?!
- if (found) {
-
- // Open the startup INIT, and grab its TDid 0 resource.
- short refNum = FSpOpenResFile(&xDBGR_Startup, fsRdPerm);
-
- Handle ourTDid = Get1Resource('TDid', 0);
-
- // if (ourTDid == NULL)
- // DebugStr("\pFailed to find TDid resource.");
-
- if (ourTDid != NULL) {
-
- dirID = ** ((long **) ourTDid);
-
- CloseResFile(refNum);
-
- // Now, find The Debugger by file name in that directory (dirID)
-
- /* theErr = */ FSMakeFSSpec(-1, dirID, "\pThe Debugger", &debuggerSpec);
-
-
- // Next, open it, and find the 'mctb' 0 [menu color table] resource.
- // The six bytes at offset 0x18 are an RGB color.
-
- refNum = FSpOpenResFile(&debuggerSpec, fsRdWrPerm);
-
- mctbRes = Get1Resource('mctb', 0);
-
- if (mctbRes == NULL) {
- // DebugStr("\pFailed to find mctb resource");
- CloseResFile(refNum);
- }
-
- if (mctbRes != NULL) {
-
- Ptr colorPointer = (*mctbRes + 0x18);
- RGBColor currentColor = *(RGBColor *) colorPointer;
-
- // Don't bother changing anything if it's already set up
- // for the right color. This ought to be the normal case, anyway.
- if (currentColor.red != machineColor.red ||
- currentColor.green != machineColor.green ||
- currentColor.blue != machineColor.blue) {
-
- // DebugStr("\pSetting color value...");
-
- // Modify the resource in memory
- *(RGBColor *)colorPointer = machineColor;
-
- // Make sure it gets written to disk
- ChangedResource(mctbRes);
- WriteResource(mctbRes);
- UpdateResFile(refNum);
- }
-
- CloseResFile(refNum);
-
- }
-
- }
-
- }
-
- }
-
-
-
- // restore to original heap
- // (We probably don't need to do this, either.)
- SetZone(theZone);
- // restore globals
- ExitCodeResource();
- }
-
-